<?php
include("header.php");
include("functions.php");
$pageTitle = "Adsense";
if($_SESSION['user_level'] != 1 )
{
	header("location: redirect.php");
}
else
 {
 if($_SERVER['REQUEST_METHOD'] == 'POST')
{ 
$filename = "../style/".$default_style."/adsense.html";
$newdata = $_POST['newd'];
if ($newdata != '') {
$fw = fopen($filename, 'w') or die('Could not open file!');
$fb = fwrite($fw,stripslashes($newdata)) or die('Could not write 
to file');
fclose($fw);
write_value_of('$adsense_name',"$adsense_name",trim($_POST['ad_name']));
echo "<b>Information</b><hr><br /><div align='center'>Configuration updated successfully.<br /><br /><a href = 'adsense.php'>Back to previous page</a></div>";
}
}
 if($_SERVER['REQUEST_METHOD'] != 'POST')
{ 
$self = "";
$filename = "../style/".$default_style."/adsense.html";
$ads_name = get_value_of('$adsense_name'); $adsense_name = trim($adsense_name); 
$fh = fopen($filename, "r") or die("Could not open file!");
$data = fread($fh, filesize($filename)) or die("Could not read file!");
fclose($fh);
 echo "<table style='width:600px;'><tr><td><h3>Adsense template</h3>
<form action='' method= 'post' ></td></tr><tr><td>
Adsense name<input value='".$ads_name."' id='forum' type='text' name='ad_name' size='30'/><br/>
<textarea name='newd' cols='100' rows='60'>$data</textarea><br/><br/>
<input class='menuButtons' type='submit' value='Save template'>
</form></td></tr></table><br/><br/><br/><br/>";
}
}
$pageContents = ob_get_contents (); 
ob_end_clean ();
echo str_replace ('<!--TITLE-->', $pageTitle, $pageContents);  
?> 